using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace SmartContentUI.Admin.User
{
    public partial class UserList : UserControl
    {
        #region Variables
        private SmartContentBusiness.Session session;
        public delegate void UserSelected(SmartContentDB.Interfaces.User user);
        public event UserSelected UserChange;
        #endregion

        #region Constructor
        public UserList(SmartContentBusiness.Session ses)
        {
            InitializeComponent();
            session = ses;
        }
        #endregion

        #region Public Methods
        public void fillUsers()
        {
            SmartContentDB.Interfaces.User[] users = this.session.getUsers();
            if (users != null)
            {
                this.user_lbox.Items.Clear();
                this.user_lbox.Items.AddRange(users);
            }
        }
        #endregion

        #region Private Methods
        private void user_lbox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SmartContentDB.Interfaces.User user = (SmartContentDB.Interfaces.User)this.user_lbox.SelectedItem;
            if (user != null)
            {
                UserChange(user);
            }
        }
        #endregion
    }
}
